package com.example.demo.service;

import com.example.demo.dao.mapper.TestBeanMapper;
import com.example.demo.dao.model.TestBean;
import com.example.demo.dao.model.TestBeanCriteria;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
//@Transactional(value = "transactionManager", rollbackFor = Exception.class,
//        isolation = Isolation.READ_COMMITTED, timeout = 300)
public class TestService implements ITestService {
    @Autowired
    private TestBeanMapper mapper;
    @Override
    public List<TestBean> advanceSearch(String keyword, Integer pageIndex, Integer pageSize) {
        TestBeanCriteria criteria = new TestBeanCriteria();
        criteria.createCriteria().andNameLike('%' + keyword + '%');
        PageHelper.startPage(pageIndex, pageSize);
        return mapper.selectByCriteria(criteria);
    }
}
